package JiHe;

import java.util.Map;
import java.util.TreeMap;

public class Test6 {
    //TreeMap的自然排序指的是字典排序
    public static void main(String[] args) {
        Map<Integer,String> map=new TreeMap<Integer, String>();
        map.put(4,"a");//key按照数字大小
        map.put(3,"a");
        map.put(2,"a");
        map.put(1,"a");
        System.out.println(map);//1=a, 2=a, 3=a, 4=a

        Map<String,String> map1=new TreeMap<String,String>();
        map1.put("a","b");//key按照字典先数字再字母
        map1.put("ba","b");
        map1.put("bc","b");
        map1.put("ad","ba");
        map1.put("1","a");
        map1.put("100","1");
        System.out.println(map1);//1=a, 100=1, a=b, ad=ba, ba=b, bc=b
    }
}
